package com.wrupple.muba.catalogs.client.widgets.fields.providers;

import com.google.gwt.cell.client.Cell;
import com.google.gwt.event.shared.EventBus;
import com.google.inject.Inject;
import com.wrupple.muba.catalogs.client.activity.process.task.CatalogInteractionState.Mode;
import com.wrupple.muba.catalogs.client.module.services.presentation.CatalogFormFieldProvider;
import com.wrupple.muba.catalogs.client.widgets.fields.cells.RichTextCell;
import com.wrupple.muba.catalogs.client.widgets.impl.CatalogUserInterfaceMessages;
import com.wrupple.muba.common.shared.Process;
import com.wrupple.muba.common.shared.SequentialProcess;
import com.wrupple.muba.common.shared.State.ProcessManager;
import com.wrupple.muba.widget.client.widgets.forms.RichTextEditor;
import com.wrupple.vegetate.domain.FieldDescriptor;

public class RichTextFieldProvider implements CatalogFormFieldProvider {

	CatalogUserInterfaceMessages msgs;
	
	@Inject
	public RichTextFieldProvider(CatalogUserInterfaceMessages msgs) {
		super();
		this.msgs = msgs;
	}



	@Override
	public Cell<String> createCell(EventBus bus, ProcessManager pm, FieldDescriptor d, Mode mode)  {
		Cell<String> regreso;
		RichTextEditor wrap = new RichTextEditor();
		String name = msgs.richTextEditingProcess();
		Process<String, String> process = SequentialProcess.wrap(wrap, wrap, name);
		regreso = new RichTextCell(bus, pm, d, mode, process, name);
		return regreso;
	}

}
